<template>

  <el-main>
    <el-table
        :data="list"
        style="width: 100%">
      <el-table-column
          prop="name"
          label="合同"
          width="120">
      </el-table-column>
      <el-table-column
          prop="total"
          label="合同金额"
          width="120">
      </el-table-column>
      <el-table-column
          prop="categoryId"
          label="合同类型"
          width="120">
      </el-table-column>
      <el-table-column
          prop="categoryId"
          label="合同状态"
          width="120">
        <template slot-scope="scope">
          <span v-if="scope.row.status=='0'">未提交</span>
          <span v-else="scope.row.status=='1'">已提交</span>
        </template>
      </el-table-column>
      <el-table-column
          prop="userId"
          label="创建人"
          width="120">
      </el-table-column>
      <el-table-column
          fixed
          prop="date"
          label="合同日期"
          width="150">
      </el-table-column>


      <el-table-column
          label="操作"
          width="200">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small" v-if="scope.row.status==0">提交审核</el-button>
          <el-button type="text" size="small" v-if="scope.row.status==0">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-row>
      <el-button @click="deploy()" type="text" size="small">部署</el-button>
    </el-row>
  </el-main>

</template>

<script>
export default {
  name: "HeTong",
  data() {
    return {
      list:[]
    }
  },
  methods:{
    handleClick: function (row) {
      this.axios.post('/hetong/activiti/submit', row).then(res => {
        if (res.data.code == 200) {
          this.$message.success("已提交审核，合同进入审批流程，不能再修改合同了");
          this.listView();
        }
      })
    },
    deploy() {
      this.axios.get("/hetong/activiti/deploy").then(res=>{
        this.$message.success(res.data.msg)
      })
    },
    listView() {
      this.axios.get("/hetong/list").then(res=>{
        this.list = res.data.data;
      })
    }

  },
  created() {
    this.listView();
  }
}
</script>

<style scoped>

</style>